package com.etung.iot.demo.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
@Slf4j
public class WorkRunner implements CommandLineRunner {
    private static ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(3);
    @Autowired
    private EmqxTaskRunner emqxTaskRunner;

    @Autowired
    StorageRunner storageRunner;

    @Autowired
    AlarmRunner alarmRunner;

    @Override
    public void run(String... args) throws Exception {
        threadPoolExecutor.submit(emqxTaskRunner);
        threadPoolExecutor.submit(storageRunner);
        threadPoolExecutor.submit(alarmRunner);
    }
}
